package org.learn.java.suanfa.yuesefu;

import java.util.Scanner;

public class Kill {
	private static Kill kill = new Kill();
	// 人数
	int totial = 0;
	// 开始位置
	int start = 0;
	// 步长
	int length = 0;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		kill.array();
	}

	public void digui() {

	}

	public void array() {
		Scanner scanner = new Scanner(System.in);
		totial = scanner.nextInt();
		System.out.println("总人数：" + totial);
		start = scanner.nextInt();
		System.out.println("开始位置：" + start);
		length = scanner.nextInt();
		System.out.println("报数：" + length);
		boolean[] array = new boolean[totial];
		// 进度
		int run = 0;
		int begin = start - 1;
		boolean flag = true;
		for (int i = 0; i < array.length; i++) {
			array[i] = true;
		}
		while (totial > 1) {
			System.out.println("-------");
			for (int i = begin; i < array.length; i++) {
				if (totial == 1) {
					break;
				}
				if (array[i]) {
					run += 1;
					if (run % length == 0) {
						array[i] = false;
						System.out.println(i + 1 + "死亡");
						run = 0;
						totial--;
					}
				}
			}
			begin = 0;
		}
		for (int i = 0; i < array.length; i++) {
			if (array[i]) {
				System.out.println(i + 1 + "最后存活");
			}
		}
	}

}
